import request from '@/utils/request'

// 获取公告列表
export function getAnnouncements(params) {
  return request({
    url: '/api/admin/announcements',
    method: 'get',
    params: {
      page: params.page || 0,
      size: params.size || 10,
      search: params.search || ''
    }
  })
}

// 创建公告
export function createAnnouncement(data) {
  return request({
    url: '/api/admin/announcements',
    method: 'post',
    data
  })
}

// 更新公告
export function updateAnnouncement(id, data) {
  return request({
    url: `/api/admin/announcements/${id}`,
    method: 'put',
    data
  })
}

// 删除公告
export function deleteAnnouncement(id) {
  return request({
    url: `/api/admin/announcements/${id}`,
    method: 'delete'
  })
}

// 获取公告详情
export function getAnnouncement(id) {
  return request({
    url: `/api/admin/announcements/${id}`,
    method: 'get'
  })
} 